#define _CRT_SECURE_NO_WARNINGS 1
#include <climits>
#include <iostream>
#include <ostream>
using namespace std;

class Date
{
public:
    Date(int year = 1900, int month = 1, int day = 1)
        :_year(year),
        _month(month),
        _day(day)
    {}

    Date(const Date& d)
    {
        _year = d._year;
        _month = d._month;
        _day = d._day;
    }

    int GetMonthDay(int year, int month)
    {
        static int Day[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
        if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
            return 29;
        return Day[month];
    }

    Date& operator=(const Date& d)
    {
        _year = d._year;
        _month = d._month;
        _day = d._day;
        return *this;
    }

    Date operator+(int day)
    {
        Date tmp = *this;
        tmp._day += day;
        while (tmp._day > GetMonthDay(tmp._year, tmp._month))
        {
            tmp._day -= GetMonthDay(tmp._year, tmp._month);
            tmp._month++;
            if (tmp._month > 12)
            {
                ++tmp._year;
                tmp._month = 1;
            }
        }
        return tmp;
    }

    Date& operator+=(int day)
    {
        *this = *this + day;
        return *this;
    }

    Date operator-(int day)
    {
        Date tmp = *this;
        tmp._day -= day;
        while (tmp._day <= 0)
        {
            tmp._month--;
            if (tmp._month < 1)
            {
                --tmp._year;
                tmp._month = 12;
            }
            tmp._day += GetMonthDay(tmp._year, tmp._month);
        }
        return tmp;
    }

    Date& operator-=(int day)
    {
        *this = *this - day;
        return *this;
    }

    bool operator==(const Date& d)
    {
        return _year == d._year && _month == d._month && _day == d._day;
    }

    friend ostream& operator<<(ostream& cout, const Date& d)
    {
        return cout << d._year << '-' << d._month << '-' << d._day << endl;
    }

private:
    int _year;
    int _month;
    int _day;
};

int main() {
    Date d1(2020, 2, 20);
    d1 -= 10;
    Date d2 = d1 + 100;
    cout << d1;
    cout << d2;
    if (d1 == d2) cout << 1;
    else cout << 0;
}